<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<title>我的订单</title>
		<link href="css/myinvest-style.css" rel="stylesheet" type="text/css">
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="admin-html/css/font.css">
		<link rel="stylesheet" href="admin-html/css/xadmin.css">
		<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
		<script src="admin-html/js/jquery.min.js"></script>
		<script type="text/javascript" src="admin-html/lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="admin-html/js/xadmin.js"></script>
	</head>
	<body>
		<section class="aui-flexView">
			<header class="aui-navBar aui-navBar-fixed">
				<a class="aui-navBar-item" onclick="window.close()">
					<i class="icon icon-return"></i>
				</a>
				<div class="aui-center">
					<span class="aui-center-title">我的理财产品</span>
				</div>
			</header>
			<section class="aui-scrollView">
				<div class="aui-order-title" id="auilist">
				</div>
			</section>
		</section>
		
		
		<script src="js/jquery.js"></script>
		<script src="js/jquery-3.1.1.js"></script>
		<script src="admin-html/js/layui.all.js"></script>
		<script src="./admin-html/lib/layui/layui.js"></script>
		<script src="admin-html/js/xadmin.js"></script>
		<script type="text/javascript">
			//查询用户卡
			$.ajax({
				url: "http://www.longm.top:8080/lm/Card/QueryUserCard",
				type: "POST",
				dataType: "json",
				headers: {
					'Content-Type': 'application/json',
					"token": window.localStorage.getItem("token")
				},
				cache: false,
				async: true,
				contentType: "application/x-www-form-urlencoded",
				data: {},
				success: function(res) {
					console.log(JSON.stringify(res));
					if (res.code === 200) {
						var result = res.data
						for (var i = 0; i < result.length; i++) {
							myCkList(result[i].cardid);
						}
					}

				}
			});

			function myCkList(cardid) {
				json = {
					"cardid": cardid
				};
				$.ajax({
					url: "http://www.longm.top:8080/lm/ck/getMyckListbyCardid",
					type: "POST",
					dataType: "json",
					headers: {
						'Content-Type': 'application/json',
						"token": window.localStorage.getItem("token")
					},
					cache: false,
					async: false,
					data: JSON.stringify(json),
					contentType: "application/x-www-form-urlencoded",
					success: function(result) {
						console.log(JSON.stringify(result));
						var zczq = result.data.zczq;
						var hqck = result.data.hqck;
						var auilist = document.getElementById("auilist");
						if (zczq != null) {
							for (i = 0; i < zczq.length; i++) {
								var name = "定期存款";
								var date1 = new Date(zczq[i].createdate);
								var date2 = new Date(zczq[i].enddate);
								var a1 = Date.parse(new Date(date1));
								var a2 = Date.parse(new Date(date2));
								var day = parseInt((a2-a1)/ (1000 * 60 * 60 * 24));
								var html = '<div class="aui-order-box">' +
									'<a class="aui-well-item">' +
									'<div class="aui-well-item-bd">' +
									'<h3>' + name + '</h3>' +
									'</div><button class="layui-btn layui-btn-normal layui-btn-radius"  onclick="tixian('+"'"+zczq[i].zczqd+"'"+')">提钱</button></a>' +
									'<p class="aui-order-fl aui-order-time">购买金额(元):' + zczq[i].money + '</p>' +
									'<p class="aui-order-fl aui-order-address">购买时间:' + dateFormat("YYYY-mm-dd HH:MM", date1) + '</p>' +
									'<p class="aui-order-fl aui-order-door">结束时间:' + dateFormat("YYYY-mm-dd HH:MM", date2) + '</p>'+
									'<p class="aui-order-fl aui-order-door">利率:' + zczq[i].cdtypeid+'%</p>'+
									'<p class="aui-order-fl aui-order-door">预计收益:' + zczq[i].money*(zczq[i].cdtypeid/100)/360*day+'元</p>'
									+'</div>';
								auilist.innerHTML = auilist.innerHTML + html;
							}

						}
						if (hqck != null) {
							for (j = 0; j < hqck.length; j++) {
								var name = "活期存款";
								var date = new Date(hqck[j].createdate);
								var html = '<div class="aui-order-box">' +
									'<a class="aui-well-item">' +
									'<div class="aui-well-item-bd">' +
									'<h3>' + name + '</h3>' +
									'</div><button class="aui-well-item-fr" onclick="tixian1('+"'"+hqck[j].xdckid+"'"+')">提钱</button></a>' +
									'<p class="aui-order-fl aui-order-time">购买金额(元):' + hqck[j].money + '</p>' +
									'<p class="aui-order-fl aui-order-address">购买时间:' + dateFormat("YYYY-mm-dd HH:MM", date) + '</p>';
								auilist.innerHTML = auilist.innerHTML + html;
							}
						}
					}
				});
			};

			function dateFormat(fmt, date) {
				let ret;
				const opt = {
					"Y+": date.getFullYear().toString(), // 年
					"m+": (date.getMonth() + 1).toString(), // 月
					"d+": date.getDate().toString(), // 日
					"H+": date.getHours().toString(), // 时
					"M+": date.getMinutes().toString(), // 分
					"S+": date.getSeconds().toString() // 秒
					// 有其他格式化字符需求可以继续添加，必须转化成字符串
				};
				for (let k in opt) {
					ret = new RegExp("(" + k + ")").exec(fmt);
					if (ret) {
						fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
					};
				};
				return fmt;
			}
		</script>
		<script type="text/javascript">
			function tixian(id){
				localStorage.setItem("id",id);         
				window.location.href = "admin-html/html/admin/add/admin-add.html";
			}
			function tixian1(id){
				localStorage.setItem("id",id);         
				window.location.href = "admin-html/html/admin/add/admin-add1.html";
			}
		</script>
	</body>
</html>
